package org.pp.controller;


import io.swagger.v3.oas.annotations.Operation;
import org.pp.core.PageBean;
import org.pp.core.Result;
import org.pp.miniapp.dto.GoodsSearch;
import org.pp.service.IPpGoodsService;
import org.pp.vo.AdminMiniappGoodsDetailVo;
import org.pp.vo.MiniappGoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/goods")
public class PpGoodsController {

    @Autowired
    IPpGoodsService goodsService;


    @PostMapping("/search")
    @Operation(summary = "商品搜索")
    public Result<PageBean<MiniappGoodsVo>> search(@RequestBody @Validated GoodsSearch dto){
        return Result.ok(goodsService.search(dto));
    }

    @GetMapping("/detail")
    @Operation(summary = "获取商品详情")
    public Result<AdminMiniappGoodsDetailVo> getDetail(@RequestParam(name = "goodsId",required = true) Long goodsId){
        return Result.ok(goodsService.getDetail(goodsId));
    }
}
